298        Bioinformatics

7.3.6.1.4  Midpoint Rooting

Then, we can define the root of the phylogenetic tree as its midpoint.

qiime phylogeny midpoint-root \

--i-tree trees/unrooted-denovoTr-tree.qza \

--o-rooted-tree trees/rooted-denovoTr-tree.qza

Now, we have created both unrooted and rooted phylogenetic trees using de novo approach.

The tree artifact can be exported into NEWICK tree file format which can be viewed on any

tree viewing program such as ETE toolkit. In the following, we will use “export” method of

“q2-tools” plugin to export phylogenetic tree data into NEWICK tree files:

qiime tools export \

--input-path trees/unrooted-denovoTr-tree.qza \

--output-path tree/unrooted

qiime tools export \

--input-path trees/rooted-denovoTr-tree.qza \

--output-path trees/rooted

7.3.6.2  Fragment-Insertion Phylogenetic Tree

A phylogenetic tree based on aligning the representative sequences to reference sequences

can be constructed with “q2-phylogeny” using “align-to-tree-mafft-fasttree” method, which

takes representative sequences as an input and outputs four artifacts: aligned sequences,

masked alignments, unrooted tree, and rooted tree. The following script creates unrooted

tree and rooted tree and export them to NEWICK files:

mkdir trees2

qiime phylogeny align-to-tree-mafft-fasttree \

--i-sequences dada2/rep-seqs_yoga_dada2.qza \

--o-alignment trees2/rep-seqs_yoga_dada2_alignedTr.qza \

--o-masked-alignment trees2/rep-seqs_yoga_dada2_maskedTr.qza \

--o-tree trees2/unrooted-tree-yoga_dada2.qza \

--o-rooted-tree trees2/rooted-tree-yoga_dada2.qza

qiime tools export \

--input-path trees2/unrooted-tree-yoga_dada2.qza \

--output-path trees2/unrooted

qiime tools export \

--input-path trees2/rooted-tree-yoga_dada2.qza \

--output-path trees2/rooted

7.3.7  Alpha and Beta Diversity Analysis

Above, we discussed the alpha and beta diversity and the metrics used for each type. In the

following, we will show you how to use QIIME2 to compute these metrics.

We will use the “q2-diversity” plugin to generate the phylogenetic and non-phylogenetic

diversity metrics. This plugin creates an artifact that contains both alpha and beta diversity